/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * SimulCronog.java
 *
 * Created on 05/01/2012, 10:25:42 AM
 */
package Vista;

import java.util.Calendar;
import java.util.Vector;

/**
 *
 * @author jose,digberht
 */
public class SimulCronog extends javax.swing.JFrame {

    Vector <String[]> contenido_resultados_temp;
    public Object contenido_resultados[][];
    String etiquetas_resultados[];
    
    private int capital;
    private String nombre;
    private int codigo;
    private int interes;
    private int plazo;
    private static  Calendar fecha;
    static  String [] d;
    /** Creacion de un nuevo formulario SimulCronog */
    public SimulCronog(String [] datos,Calendar f) {
        
        d=new String[5];
        this.d=datos;
        this.nombre=datos[0];
        this.codigo=Integer.parseInt(datos[1]);
        this.capital=Integer.parseInt(datos[2]);
        this.plazo=Integer.parseInt(datos[3]);
        this.interes=Integer.parseInt(datos[4]);
        this.fecha=f;
        
        contenido_resultados_temp= new Vector<String[]>();
        etiquetas_resultados=new String[] {"Nro.", "Fecha", "Capital", "Interes", "Cuota", "Saldo"};
        contenido_resultados=new Object[this.plazo][6];
  
        int couta=(capital/plazo);
            for (int i = 0; i < contenido_resultados.length; i++) {
                contenido_resultados[i][0]=String.valueOf(i+1);
            }
        for (int i = 0; i < contenido_resultados.length; i++) {
                fecha.add(Calendar.MONTH, 1);
                contenido_resultados[i][1]=new java.sql.Date(fecha.getTimeInMillis()).toString();
            }
        for (int i = 0; i < contenido_resultados.length; i++) {
                contenido_resultados[i][2]=String.valueOf(capital);
            }
        for (int i = 0; i < contenido_resultados.length; i++) {
                contenido_resultados[i][3]=String.valueOf(interes);
            }
        for (int i = 0; i < contenido_resultados.length; i++) {
                contenido_resultados[i][4]=String.valueOf(couta);
            }
        int temp=capital;
        for (int i = 0; i < contenido_resultados.length; i++) {
            temp=temp-couta;
                contenido_resultados[i][5]=String.valueOf(temp);
            }
        initComponents();
        jTable_ResulCronograma.setModel(new javax.swing.table.DefaultTableModel(contenido_resultados,etiquetas_resultados)); 
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel5 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable_ResulCronograma = new javax.swing.JTable();
        jButton_Resul_Cerrar = new javax.swing.JButton();
        jButton_Resul_Imprimir = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Cronograma"));

        jTable_ResulCronograma.setModel(new javax.swing.table.DefaultTableModel(
            contenido_resultados,
            etiquetas_resultados
        ) {
            Class[] types = new Class [] {
                java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Integer.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane3.setViewportView(jTable_ResulCronograma);

        jButton_Resul_Cerrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/salisr.JPG"))); // NOI18N
        jButton_Resul_Cerrar.setText("Cerrar");
        jButton_Resul_Cerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_Resul_CerrarActionPerformed(evt);
            }
        });

        jButton_Resul_Imprimir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/imprimir.JPG"))); // NOI18N
        jButton_Resul_Imprimir.setText("Imprimir");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap(458, Short.MAX_VALUE)
                .addComponent(jButton_Resul_Imprimir, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton_Resul_Cerrar, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 666, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 77, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton_Resul_Cerrar)
                    .addComponent(jButton_Resul_Imprimir))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 718, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 431, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(12, 12, 12)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
/** Funcion de evento del boton cerrar que cierra la ventana actual activa */
private void jButton_Resul_CerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_Resul_CerrarActionPerformed
// TODO add your handling code here:
    this.dispose();
}//GEN-LAST:event_jButton_Resul_CerrarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(SimulCronog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(SimulCronog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(SimulCronog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(SimulCronog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new SimulCronog(d,fecha).setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton_Resul_Cerrar;
    private javax.swing.JButton jButton_Resul_Imprimir;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTable jTable_ResulCronograma;
    // End of variables declaration//GEN-END:variables
}
